package com.ghck.shop.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

import com.ghck.shop.dao.provider.SellerMapperProvider;
import com.ghck.shop.model.Seller;


public interface SellerMapper {

	@Insert("insert into t_seller"
			+ "(user_id,contact_name,contact_phone,card_num,shop_name,apply_category,card_front,card_back,business_licence,status,create_time,last_modify_time)"
			+ "values"
			+ "(#{userId},#{contactName},#{contactPhone},#{cardNum},#{shopName},#{applyCategory},#{cardFront},#{cardBack},#{businessLicence},#{status},#{createTime},#{lastModifyTime})")
	public Integer addSeller(Seller seller);
	
	@Update("update t_seller set status=#{status} where id=#{id}")
	public Integer updateSellerStatus(@Param("id")Integer id,@Param("status")Integer status);
	
	@Select("select * from t_seller where user_id=#{userId} order by last_modify_time desc limit 1")
	public Seller findSellerByUserId(@Param("userId")Integer userId);
	
	
	@Select("select * from t_seller where id=#{id}")
	public Seller findSellerById(@Param("id")Integer id);
	
	@SelectProvider(type=SellerMapperProvider.class,method="listSellers")
	public List<Seller> listSellers(@Param("seller")Seller seller, @Param("start")Integer start, @Param("limit")Integer limit);
	
	@SelectProvider(type=SellerMapperProvider.class,method="countListSellers")
	public Integer countListSellers(@Param("seller")Seller seller);
	
}
